import Vue from 'vue'
import App from './App.vue'
import router from './router'
//引入加密md5
import md5 from 'js-md5';
// 导入全局样式表
import  './assets/css/global.css'
// Vue仓库
import store from './store'
import axios from './http'
import ElementUI from 'element-ui';
import instance from './http/index'
import 'element-ui/lib/theme-chalk/index.css';

import shopMessage from './emptyWoo'

Vue.prototype.$md5 = md5;
Vue.prototype.$axios = instance
Vue.prototype.$store = store;
Vue.use(ElementUI);
Vue.use(axios)
Vue.config.productionTip = false

Vue.prototype.$shopMessage = shopMessage;



if (sessionStorage.getItem('store')) {
  store.replaceState(
    Object.assign({},
      store.state,
      JSON.parse(sessionStorage.getItem('store'))
    )
  )
  sessionStorage.removeItem('store')
}

// 监听，在页面刷新时将vuex里的信息保存到sessionStorage里
window.addEventListener('beforeunload', () => {
  sessionStorage.setItem('store', JSON.stringify(store.state))
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
